<?php
include (dirname(dirname(__FILE__)) . "/zhconfig/Config.php");
if (! isset($_SESSION)) {
    session_start();
}

$conn1=new \ZHMVC\D\Module();
$datas1=$conn1->getAll();
$rows1=$conn1->getRows();
for($j=0;$j<$rows1;$j++)
{
    $data1=$datas1[$j];
    $moduleid=$data1['id'];
    $biaoqianzhui=$data1['biaoqianzhui'];
    $conn=new \ZHMVC\D\ModuleTable();
    $datas=$conn->getAll("moduleid='".$moduleid."'");

    $rows=$conn->getRows();
    
    for($k=0;$k<$rows;$k++)
    {
        var_dump($k);
        $data=$datas[$k];
        $tablename=strtolower($biaoqianzhui.$data['classname']);
        $rs = new \ZHMVC\D\ShowTables();
        $s = $rs->getColumns($tablename);
        
        for ($i = 0, $imax = count($s); $i < $imax; $i ++) {
            $liename="";
            if($s[$i]['comment']!="")
            {
                $liename=$s[$i]['comment'];
            }
            else
            {
                $liename=$s[$i]['field'];
            }
            $sql2="select id,isshow,xuhao from zhmvc_yctable where `datatable`='".$tablename."' and liename='".$s[$i]['field']."'";
            //echo $sql."<br>";
            $data2 = $rs->getSqlOne($sql2);
            $rows2 = $rs->getRowCount();
            //echo $rows;
            if($rows2>0)
            {
                
            }
            else
            {
                $IdWorker = \wantp\Snowflake\IdWorker::getIns();
                $id = $IdWorker->id();
                $sql1="insert into zhmvc_yctable(`id`,`datatable`,`liename`,`colindex`,`lietagname`,`isshow`,`xuhao`) values ('".$id."','".$tablename."','".$s[$i]['field']."','0','".$s[$i]['comment']."','1','0')";
                $rs->SqlUpdate($sql1);
            }
        }
    }
}

